using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Utility;
using Entities;

public partial class Admin_Themamthuc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        //try
        //{
        tbAmthuc  athuc = new tbAmthuc ();
        athuc.Tenamthuc  = txttenat.Text;
       
        athuc.Mota  = txt_mota.Text;

        if (img_at.HasFile)
        {
            string filename = DateTime.Now.Ticks.ToString() + "_" + img_at.FileName;
            img_at.SaveAs(Server.MapPath("~/Hinhanh/" + filename));
            System.Drawing.Image img = System.Drawing.Image.FromFile(
                Server.MapPath("~/Hinhanh/" + filename));
            ImageUtility.MakeThumbnailPhoto(
                img, 100, 100, Server.MapPath("~/Hinhanh/Hinh/"), filename);
            athuc.Hinhanh  = filename;
        }
        else
        {
            athuc.Hinhanh  = "no_images.jpg";
        }
        tbAmthucBUS .Insert(athuc);

        Response.Redirect("~/Admin/Danhsachamthuc.aspx");
       
    }
}
